package com.example.service;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.example.demo.user_infoModel;
import com.example.mapper.UserMapper;
import com.example.user_repository.userRepository;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service
public class UserService {
	
	@Resource
	private userRepository userRepository;
	
	@Resource
	private UserMapper userMapper;
	/**
	 * save,update,delete
	 */
	
	@Transactional
	public void save(user_infoModel user){
		userRepository.save(user);
	}
	@Transactional
	public void delete(int id){
		userRepository.delete(id);
	}
	@Transactional
	public void update(user_infoModel user){
		userRepository.save(user);
	}
	public Iterable<user_infoModel> list(){
		return userRepository.findAll();
	}
	
	public List<user_infoModel> getAllUser(){
		List<user_infoModel> allUser = userMapper.getAllUser();
		return allUser;
	}
	
	public List<user_infoModel> getUserByName(String name){
		List<user_infoModel> allUser= userMapper.getUserByName(name);
		return allUser;
	}
}
